package com.l024.easyandroidlib.log.log;


import com.l024.easyandroidlib.log.config.EasyLogConfig;
import com.l024.easyandroidlib.log.printer.EasyLogPrinter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wu_ming_zhi_bei
 * @date 2021/1/28 21:43
 * @Notes 日志管理类
 */
public class EasyLogManager {
    private EasyLogConfig config;
    private static EasyLogManager instance;
    private List<EasyLogPrinter> printers = new ArrayList<>();

    private EasyLogManager(EasyLogConfig easyLogConfig, EasyLogPrinter[] printers) {
        this.config = easyLogConfig;
        this.printers.addAll(Arrays.asList(printers));
    }

    public static EasyLogManager getInstance(){
        return instance;
    }

    public static void init(EasyLogConfig config, EasyLogPrinter... printers){
        instance = new EasyLogManager(config,printers);
    }

    public EasyLogConfig getConfig(){
        return config;
    }

    public List<EasyLogPrinter> getPrinters(){
        return printers;
    }

    public void addPrinter(EasyLogPrinter easyLogPrinter){
        printers.add(easyLogPrinter);
    }

    public void removePrinter(EasyLogPrinter easyLogPrinter){
        if(printers!=null){
            printers.remove(easyLogPrinter);
        }
    }
}
